package exemplos.layouts.tilepane;

import java.util.Random;

import javafx.application.Application;
import javafx.geometry.Orientation;
import javafx.geometry.Pos;
import javafx.geometry.Rectangle2D;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.TilePane;


public class TilePaneSample2 extends Application {


    public void start(Stage primaryStage) throws Exception {
        Group root = new Group();
        primaryStage.setResizable(false);
        primaryStage.setScene(new Scene(root, 800, 640));
		ImageView img = new ImageView(new Image(getClass().getResourceAsStream("tiles.png")));
		ImageView tiles[] = new ImageView[500];
		
//		tilePane.setPrefColumns(25);
//		tilePane.setPrefRows(20);
		for(int i = 0; i < tiles.length; i++) {
			tiles[i] = new ImageView(img.getImage());
			tiles[i].setViewport(new Rectangle2D(new Random().nextInt(3) * 32, 0, 32, 32));
		}
		
		
//		tilePane.getChildren().addAll(tiles);
//		root.getChildren().add(tilePane);
        primaryStage.show();
    }
    public static void main(String[] args) { launch(args); }
}
